package com.zoranjoka.chordis.pages;

import org.apache.tapestry5.annotations.InjectPage;

import com.zoranjoka.chordis.Song;
import com.zoranjoka.chordis.beans.AlbumBean;
import com.zoranjoka.chordis.beans.ArtistBean;
import com.zoranjoka.chordis.beans.SongBean;
import com.zoranjoka.chordis.data.IDataArtist;
import com.zoranjoka.chordis.data.IDataSong;
import com.zoranjoka.chordis.data.MockDataArtist;
import com.zoranjoka.chordis.data.MockDataSong;

public class AddSong {
	private String id;
	private ArtistBean artist;
	private AlbumBean album;
	private String albumName;
	
	private String name;
	
	private Song song;
	
	@InjectPage
	private AddSong page;

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public ArtistBean getArtist() {
		return artist;
	}

	public void setArtist(ArtistBean artist) {
		this.artist = artist;
	}

	public AlbumBean getAlbum() {
		return album;
	}

	public void setAlbum(AlbumBean album) {
		this.album = album;
	}

	public String getAlbumName() {
		return albumName;
	}

	public void setAlbumName(String albumName) {
		this.albumName = albumName;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
	
	Object onSubmitFromAddSongForm(){
        IDataSong s = new MockDataSong();
        artist = new ArtistBean();
        //artist.setArtistID(id);
        artist.setArtistName(albumName);

        if(!s.getAllSongs().contains((SongBean)song)){
            s.addSongBean((SongBean) song);
            page.setName("Song "+getName()+" is successfuly added!");
        }
        else{
            page.setName("Song exists!!!");
        }
        return page;
    }
}
